package com.outputstream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-28
 */
public class Test {
    public static void main(String[] args) {
        String fileParent = "D:\\CScode\\code\\java_code\\2024\\t0728\\src\\com";
        String fileSon = "hello2.txt";
        File fileName = new File(fileParent, fileSon);

        FileOutputStream fileOutput = null;

        try {
            fileOutput = new FileOutputStream(fileName);
            String str = "hahahahahhahah";
            fileOutput.write(str.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("FileOutputStream失败");
        } finally {
            try {
                fileOutput.close();
            } catch (IOException e) {
                System.out.println("fileOutput关闭失败");;
            }
        }
    }
}
